package handling.opcode

/**
 * 免责声明：本模拟器源代码下载自ragezone.com，仅用于技术研究学习，无任何商业行为。
 */

enum class ZeroMask constructor(val value: Short, val TT: Short) {

    EYE_ACCESSORY(1.toShort(), 3.toShort()),
    HAT(2.toShort(), 1.toShort()),
    FOREHEAD(4.toShort(), 2.toShort()),
    EARRING(8.toShort(), 4.toShort()),
    CAPE(16.toShort(), 9.toShort()),
    TOP(32.toShort(), 5.toShort()),
    GLOVE(64.toShort(), 8.toShort()),
    WEAPON(128.toShort(), 11.toShort()),
    BOTTOM(256.toShort(), 6.toShort()),
    SHOE(512.toShort(), 7.toShort()),
    RING3(1024.toShort(), 12.toShort()),
    RING2(2048.toShort(), 13.toShort()),
    RING1(4096.toShort(), 15.toShort());

    fun check(n: Int): Boolean {
        return n and this.value.toInt() != 0x0
    }

    companion object {

        fun getZeroMask(mask: Int): ZeroMask? {
            return values().firstOrNull { it.value.toInt() == mask }
        }
    }
}